import {
  HTTP
} from '../utils/http.js';

import {
  enums
} from '../utils/enums';

class CategoryModel extends HTTP {

  /**
   * 初始化首页导航
   */
  initCategories() {
    var categories = wx.getStorageSync(enums.category);
    if (!categories) {
      this.getCategories();
    }
  }

  /**
   * 查询分类
   */
  getCategories() {
    this.request({
      url: 'category/categories'
    }).then(res => {
      wx.setStorageSync(enums.category, res.data);
    });
  }

}

export {
  CategoryModel
}